<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>GridLAB-D&trade; - GUI Example 4</title>
</head>

<script src="/rt/gridlabd.js"></script>

<body onload="refresh();" onunload="GLDAction('quit');" >

<table>
<tr><td>Test of</td><td><div id="nhouses"> &ndash; </div></td><td>houses</td></tr>
</table>

<table>
<tr><th>Location</th><td><div id="location"> &ndash; </div></td></tr>
<tr><th>Floorarea mean</th><td><div id="avg"> &ndash; </div></td></tr>
<tr><th>Floorarea stdev</th><td><div id="std"> &ndash; </div></td></tr>
<tr><th>Clock</th><td><div id="clock"> &ndash; </div></td></tr>
</table>

<script type="text/javascript">
var nhouses = GLDGetGlobal("NHOUSES");
document.getElementById("nhouses").innerHTML = nhouses;
document.getElementById("avg").innerHTML = GLDGetGlobal("AVG_SF");
document.getElementById("std").innerHTML = GLDGetGlobal("STD_SF");
document.getElementById("clock").innerHTML = GLDGetGlobal("clock");
document.getElementById("location").innerHTML = GLDGetProperty("climate:0","tmyfile");

document.writeln("<table rules='inside'>");
document.writeln("<tr><th>House</th><th>Air temperature</th><th>System mode</tr>");
for (n = 0; n < nhouses; n++) {
	document.writeln("<tr><td>" + n + "</td><td><div id='tair" + n + "'> &ndash; </div></td><td><div id='mode" + n + "'> &ndash; </div></td></tr>");
}
document.writeln("</table>");

document.getElementById("avg").value = GLDGetGlobal("AVG_SF");
document.getElementById("std").innerHTML = GLDGetGlobal("STD_SF");

refresh();

function refresh()
{
    document.getElementById("clock").innerHTML = GLDGetGlobal("clock");
    for ( n=0 ; n<nhouses ; n++)
    {
        document.getElementById("tair"+n).innerHTML = GLDGetProperty("house:"+(n+2),"air_temperature");
        document.getElementById("mode"+n).innerHTML = GLDGetProperty("house:"+(n+2),"system_mode");
    }
    document.getElementById("graph1").src = "/output/please_wait.png";
    document.getElementById("graph1").src = "/gnuplot/temps.plt?image/png";
//    document.getElementById("graph1").src = "/r/temps.r?image/png";
    setTimeout("refresh()",1000);
}
</script>

<img id="graph1" src="/output/please_wait.png" alt="My data" height=480 width=640 />

<input type="submit" value="Quit" onclick="window.close();" />

</body>
</html>
